package com.gomoku;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;

public class ReplayMenu extends JFrame {
    public ReplayMenu() {
        setTitle("游戏记录与回放");
        setSize(400, 300);
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setLocationRelativeTo(null);
        setResizable(false);

        JPanel panel = new JPanel(new GridLayout(4, 1, 10, 10));
        panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

        JButton loadReplayBtn = new JButton("加载游戏记录");
        JButton saveGameBtn = new JButton("保存当前游戏");
        JButton viewRecordsBtn = new JButton("查看游戏记录");
        JButton backBtn = new JButton("返回主菜单");

        loadReplayBtn.addActionListener(e -> {
            dispose();
            new LoadReplayFrame().setVisible(true);
        });

        saveGameBtn.addActionListener(e -> {
            // 在实际应用中，这里应该保存当前游戏状态
            JOptionPane.showMessageDialog(this, "游戏保存功能待实现", "提示", JOptionPane.INFORMATION_MESSAGE);
        });

        viewRecordsBtn.addActionListener(e -> {
            dispose();
            new ViewRecordsFrame().setVisible(true);
        });

        backBtn.addActionListener(e -> {
            dispose();
            new MainMenu().setVisible(true);
        });

        panel.add(loadReplayBtn);
        panel.add(saveGameBtn);
        panel.add(viewRecordsBtn);
        panel.add(backBtn);

        add(panel);
    }
}